dnl Process this file with autoconf to produce a configure script.
AC_INIT(libaudiofile/aiff.c)

PACKAGE=audiofile
AUDIOFILE_MAJOR_VERSION=0
AUDIOFILE_MINOR_VERSION=2
AUDIOFILE_MICRO_VERSION=6
AUDIOFILE_VERSION=${AUDIOFILE_MAJOR_VERSION}.${AUDIOFILE_MINOR_VERSION}.${AUDIOFILE_MICRO_VERSION}

dnl set version info for libaudiofile.so to package rev - $MAJOR + $MINOR : $MICRO : $MINOR
AUDIOFILE_VERSION_INFO=2:6:2

AC_SUBST(AUDIOFILE_MAJOR_VERSION)
AC_SUBST(AUDIOFILE_MINOR_VERSION)
AC_SUBST(AUDIOFILE_MICRO_VERSION)
AC_SUBST(AUDIOFILE_VERSION)
AC_SUBST(AUDIOFILE_VERSION_INFO)

VERSION=$AUDIOFILE_VERSION

AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

dnl Checks for libraries.
dnl Check for the ldexp function in the math library.
AC_CHECK_LIB(m, ldexp)

dnl Check for the SGI Audio Library function alOpenPort.
AC_CHECK_LIB(audio, alOpenPort, AUDIO_LIB=-laudio)
AC_SUBST(AUDIO_LIB)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h unistd.h inttypes.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN

dnl Disable large file support by default.
if test "x$enable_largefile" = "x"; then
	enable_largefile=no
fi
AC_SYS_LARGEFILE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T

AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(long)

dnl Workaround the lack of these types.
AC_CHECK_TYPE(u_int8_t, unsigned char)
AC_CHECK_TYPE(u_int16_t, unsigned short)
AC_CHECK_TYPE(u_int32_t, unsigned int)
AC_CHECK_TYPE(int8_t, signed char)
AC_CHECK_TYPE(int16_t, short)
AC_CHECK_TYPE(int32_t, int)

dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(strdup)

dnl Set up platform specific stuff
platform=none
AC_MSG_CHECKING([for platform specific tests to compile])
case "$host_os" in
  linux*)
    TEST_BIN="linuxtest"
    platform=linux
    ;;
  irix5* | irix6*)
    TEST_BIN="irixread irixtestloop"
    platform=irix
    ;;
  darwin*)
    if test -e /System/Library/Frameworks/CoreAudio.framework; then
      TEST_BIN="osxplay"
      platform="Mac OS X"
    fi
    ;;
esac
AC_MSG_RESULT($platform)
AC_SUBST(TEST_BIN)

AC_OUTPUT([
	audiofile.spec
	audiofile.pc
	sfcommands/Makefile 
	test/Makefile 
	examples/Makefile 
	libaudiofile/Makefile 
	libaudiofile/modules/Makefile 
	docs/Makefile 
	win32/Makefile 
	Makefile 
	audiofile-config], [case "$CONFIG_FILES" in *audiofile-config*) chmod +x audiofile-config;; esac])
